<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of wallet_model
 *
 * @author win7
 */
class invoicie_items_model extends cms_model {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->table = 'invoicie_items';
    }

    public function filter($limit = FALSE, $order = FALSE) {
        $config['total_rows'] = $this->get(array('user_id' => $this->user_id), TRUE);
        if ($limit)
            $config['per_page'] = $limit;
        else
            $config['per_page'] = 30;
        if (!$order || $order == 'up') {
            $this->order = array('id' => 'desc');
        } else {
            $this->order = array('id' => 'asc');
        }
        $data['result'] = $this->get(array('user_id' => $this->user_id), FALSE, 'result', $config['per_page']);
        //$data['pagination'] = $this->cms_pagination($url = 'index', $config['total_rows'], $config['per_page']);
        return $data;
    }
    
    function aftersave($id) {

        if (isset($this->data['bank_name']) && isset($this->data['sender_name']) && isset($this->data['account_number'])) {
            if (empty($this->data['note'])) {
                $this->data['note'] = '';
            }
            $this->db->insert('wallet_bank', array(
                'wallet_id' => $id,
                'bank_name' => $this->data['bank_name'],
                'sender_name' => $this->data['sender_name'],
                'account_number' => $this->data['account_number'],
                'note' => $this->data['note'],
            ));
        }
    }
}

?>
